package com.wwf.springbootrabbitmqordercancle.Controller;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

@RestController
public class TestOrderTTLNoPay {
    @Autowired
    private AmqpTemplate rabbitMqTemplate;

    @RequestMapping("/createOrder")
    public String createOrder(){
        int order = new Random().nextInt();
        rabbitMqTemplate.convertAndSend("orderWillPay.ex","orderWillPay.key",""+order);
        return "下单成功,订单号："+order;
    }
    @RequestMapping("/notPayOrder")
    public String notPayOrder() {
        String notGo = (String) rabbitMqTemplate.receiveAndConvert("OrderNotPayCance");
        return "取消订单号："+notGo;
    }
}
